#ifndef __CP_CTRL_H
#define __CP_CTRL_H

#include <stdint.h>
#include <stdio.h>
#include <unistd.h>

#define CHAR_SIZE				(16)
#define TABLE_SIZE				(100)
#define BUF_LEN					(4096)
#define KEYFILE					"/home/jiawei/workshop1/compilerxy/trunk/config/keyfile.txt"
#define DELIMITERFILE			"/home/jiawei/workshop1/compilerxy/trunk/config/delimiter.txt"
#define OPERATORFILE			"/home/jiawei/workshop1/compilerxy/trunk/config/operator.txt"
#define CONSTFILE				"/home/jiawei/workshop1/compilerxy/trunk/config/const.txt"
#define IDENTIFIERFILE			"/home/jiawei/workshop1/compilerxy/trunk/config/identifier.txt"
#define LEXICALFILE				"/home/jiawei/workshop1/compilerxy/trunk/config/lexical.txt"
#define LLTABLEFILE				"/home/jiawei/workshop1/compilerxy/trunk/config/ll_table.txt"

struct table {
	char ch[CHAR_SIZE];		/*keyword, identifier, operator, delimeter ?*/
	uint32_t code;			/*Its code*/
};

#if 0
enum buff_type{
};
#endif

struct ll_table {
	char vn[CHAR_SIZE];
	char vt[CHAR_SIZE];
	char pro[CHAR_SIZE];
	int is_last;
};

struct stack {
	char ch[CHAR_SIZE];
	struct stack *next;
};

struct la {
	struct table *keyword_buff;
	uint32_t kd_amount;
	struct table *operator_buff;
	uint32_t op_amount;
	struct table *delimiter_buff;
	uint32_t dt_amount;
	struct table *const_buff;
	uint32_t cs_amount;
	struct table *identifier_buff;
	uint32_t id_amount;
	struct table *lexical_buff;
	char *buff;
	gchar **v;		/* remember use g_strfreev(v) to free */
	int v_len;
	struct ll_table *analyse_table;
	int ll_len;
	struct stack *ss;
	int ss_len;
};

int la_init(struct la *);
int get_source_file(struct la *, char *);
int preprocess(struct la *);
int scan_buff2words(struct la *);
int get_words2file(struct la *);
int get_input_words(struct la *);
#endif
